﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.CodeDom.Compiler;

namespace RobotBattle2.Scripting
{
    public class InvokeExpression : Expression
    {
        public InvokeExpression() { }
        public InvokeExpression(SymbolReference targetSymbol)
        {
            this.TargetSymbol = targetSymbol;
        }

        public SymbolReference TargetSymbol { get; set; }

        public ExpressionCollection Parameters { get { return m_Parameters; } }
        private ExpressionCollection m_Parameters = new ExpressionCollection();

        public override void Dump(IndentedTextWriter writer)
        {
            writer.Write("gosub(");
            TargetSymbol.Dump(writer);
            if (Parameters.Count > 0)
            {
                writer.Write(", ");
                Parameters.Dump(writer);
            }
            writer.Write(')');
        }

        public override ExpressionType Type { get { return ExpressionType.Invoke; } }
    }
}
